-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce closure and Lazy allocations inside CSharpCompilation.ctor #72371
Reduce closure and Lazy allocations inside CSharpCompilation.ctor #72371
Conversation
These account for about 0.3% of all allocations in the CopyPlainText speedometer test.
Reorder bool assignment and CompareExchange to avoid potential usage of member when not initialized
@dotnet/roslyn-compiler -- ptal |
Done with review pass (commit 4) |
Use lazy naming convention Move away from StrongBox usage
@AlekseyTs any remaining concerns? |
@@ -92,11 +93,11 @@ internal Conversions Conversions | |||
/// <summary> | |||
/// Manages anonymous types declared in this compilation. Unifies types that are structurally equivalent. | |||
/// </summary> | |||
private readonly AnonymousTypeManager _anonymousTypeManager; | |||
private AnonymousTypeManager? _anonymousTypeManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
private NamespaceSymbol? _lazyGlobalNamespace; | ||
|
||
internal readonly BuiltInOperators builtInOperators; | ||
private BuiltInOperators? _builtInOperators; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -152,7 +153,7 @@ internal Conversions Conversions | |||
/// <summary> | |||
/// Cache of T to Nullable<T>. | |||
/// </summary> | |||
private readonly ConcurrentCache<TypeSymbol, NamedTypeSymbol> _typeToNullableVersion = new ConcurrentCache<TypeSymbol, NamedTypeSymbol>(size: 100); | |||
private ConcurrentCache<TypeSymbol, NamedTypeSymbol>? _typeToNullableVersion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_options = options; | ||
_lazyScriptClass = ErrorTypeSymbol.UnknownResultType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with review pass (commit 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 6)
Additionally, lazily create a couple members that don't appear to be used on most instances. Together, these account for about 0.8% of all allocations in the CopyPlainText speedometer test.
*** Previous allocations from test profile